package de.dhbw.ka.tit09.picsim.model.converter;

import org.eclipse.core.databinding.conversion.Converter;

/**
 * Hex string to integer converter class. Converts GUI input to model values.
 * 
 * @author Andreas Bender
 * 
 */
public class HexStringToIntConverter extends Converter {

	/**
	 * Constructor.
	 */
	public HexStringToIntConverter() {
		super(new String(), new Integer(0));
	}

	public Object convert(Object fromObject) {
		String hexString = (String) fromObject;
		return hexString.isEmpty() ? 0 : Integer.valueOf(hexString, 16);
	}

}
